import { fileURLToPath, URL } from "node:url";

import { defineConfig ,loadEnv} from "vite";
import vue from "@vitejs/plugin-vue";
import electron from 'vite-plugin-electron'
import renderer from "vite-plugin-electron-renderer";

// https://vite.dev/config/
export default ({ mode }) => {
    const isWeb = loadEnv(mode, process.cwd()).VITE_PLATFORM === "development";
    console.log(isWeb);
    const config = {
        base: isWeb ? "/" : "./",
        server: {
            port: 3004,
        },
        plugins: [
            vue(),
            electron({
                entry: 'electron/main.cjs',
            }),
            renderer(),
        ],
        resolve: {
            alias: {
                "@": fileURLToPath(new URL("./src", import.meta.url)),
            },
        },
        css: {
            preprocessorOptions: {
                less: {
                // 这里可以配置 Less 的选项
                },
            },
        },
    };
    return defineConfig(config);
};
